package cn.jjxx.modules.iface.controller;


import cn.jjxx.core.model.AjaxJson;
import cn.jjxx.core.query.wrapper.EntityWrapper;
import cn.jjxx.modules.fm.entity.*;
import cn.jjxx.modules.fm.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/iface/road-bridge-finance")
public class RoadBridgeFinanceManageController {

    @Autowired
    private IFmUnitService unitService;
    @Autowired
    private IFmFundPlanService fundPlanService;
    @Autowired
    private IFmBankAccountService bankAccountService;
    @Autowired
    private IFmAuditPaymentService auditPaymentService;
    @Autowired
    private IFmActualCostService actualCostService;
    @Autowired
    private IFmDuesService duesService;



    @RequestMapping(value = "unit")
    public AjaxJson getUnit(){
        AjaxJson json = new AjaxJson();
        FmUnit result = unitService.selectOne(null);
        json.setData(result);
        json.success("success");
        return json;
    }

    @RequestMapping(value = "fund-plan")
    public AjaxJson getFundPlan(){
        AjaxJson json = new AjaxJson();
        FmFundPlan result = fundPlanService.selectOne(null);
        json.setData(result);
        json.success("success");
        return json;
    }

    @RequestMapping(value = "dues")
    public AjaxJson getDues(){
        AjaxJson json = new AjaxJson();
        EntityWrapper<FmDues> wrapper = new EntityWrapper<>();
        wrapper.orderBy("sort");
        List<FmDues> results = duesService.selectList(wrapper);
        json.setData(results);
        json.success("success");
        return json;
    }

    @RequestMapping(value = "bank-account")
    public AjaxJson getBankAccount(){
        AjaxJson json = new AjaxJson();
        FmBankAccount result = bankAccountService.selectOne(null);
        json.setData(result);
        json.success("success");
        return json;
    }

    @RequestMapping(value = "audit-plan")
    public AjaxJson getAuditPlan(){
        AjaxJson json = new AjaxJson();
        FmAuditPayment result = auditPaymentService.selectOne(null);
        json.setData(result);
        json.success("success");
        return json;
    }

    @RequestMapping(value = "actual-cost")
    public AjaxJson getActualCost(){
        AjaxJson json = new AjaxJson();
        FmActualCost result = actualCostService.selectOne(null);
        json.setData(result);
        json.success("success");
        return json;
    }
}
